template <typename Graph, typename OutputIterator, typename ColorMap>
void topo_sort(const Graph& g, OutputIterator topo_order, ColorMap color)
{
	topo_visitor<OutputIterator> vis(topo_order);
	generic dfs
}

template <typename OutputIterator>
struct topo_visitor : public default_dfs_visitor {
	topo_visitor(OutputIterator& order) : topo_order(order) { }
	template <typename Graph>
	void finish_vertex(typename graph_traits<Graph>::vertex_descriptor u, const Graph&)
		{ *topo_order++ = u ; }
	OutputItertor& topo order ;
};

template <typename Graph, typename Visitor, typename ColorMap>
void generic_dfs_v2(const Graph& g, Visitor vis, ColorMap color)
{
	typedef color_traits<typename property_traits<ColorMap>::value_type> ColorT ;
	typename graph_traits<Graph>::vertex_iterator vi, vi_end ;
	for (boost::tie(vi, vi_end) = boost::vertices(g) ; vi != vi_end ; ++vi)
		color[*vi] = ColorT::white() ;
	for (boost::tie(vi, vi_end) = boost::vertices(g) ; vi != vi_end ; ++vi)
		if (color[*vi] == ColorT::white())
			dfs_v2(g, *vi, color, vis) ;
}

template <typename Graph, typename ColorMap, typename Visitor>
void dfs_v2(const Graph& g,
			typename graph_traits<Graph>::vertex_descriptor u,
			ColorMap color, Visitor vis)
{
	typedef typename property_traits<ColorMap>::value_type color_type ;
	typedef color_traits<color_type> ColorT ;
	color[u] = ColorT::gray() ;
	vis.discover vertex(u, g) ;
	
	typename graph_traits<Graph>::out_edge_iterator ei, ei_end ;
	
	for (boost::tie(ei, ei_end) = boost::out_edges(u, g) ; ei != ei_end ; ++ei )
		if (color[boost::target(*ei, g)] == ColorT::white()) {
			vis.tree_edge(*ei, g) ;
			dfs_v2(g, boost::target(*ei, g), color, vis) ;
		}
		else if (color[boost::target(*ei, g)] == ColorT::gray())
			vis.back_edge(*ei, g) ;
		else
			vis.forward_or_cross_edge(*ei, g) ;
		
		color[u] = ColorT::black() ;
		vis.finish vertex(u, g) ;
}